SciChart WPF 3D Charts > Advanced 3D Chart APIs > The SceneEntity API > 3D Scene Lighting
3D Scene Lighting

SciChart 3D supports static and dynamic scene lighting. Static light always follows camera direction, while direction of dynamic light can be set in world coordinates. Static light mode is the default option.

 

 

Configuring Scene Lighting

Scene lighting can be configured through a Viewport3D instance by setting one of the two available Light Modes. Current Viewport3D instance can be obtained from the Viewport3D property of SciChart3DSurface.

For example, to turn on dynamic lighting set MainLightMode to "GlobalSpace" on current Viewport3D instance:

Turning on dynamic lighting
Copy Code
var viewport3D = sciChart3DSurface.Viewport3D as Viewport3D;
viewport3D.SetMainLightMode(MainLightMode.GlobalSpace);

Configuring Light Direction

Light direction is represented by a unit vector, each component of which can range from -1 to 1.

Current light direction vector can be obtained from the Viewport3D instance through the GetMainLightDirection() method. Likewise, new light direction vector can be assigned through the SetMainLightDirection() method on the Viewport3D instance.

For example, when dynamic lighting is enabled using MainLightMode.GlobalSpace, current light direction vector can be obtained and modified in the following way:

Obtaining and modifying current light direction vector
Copy Code
var viewport3D = sciChart3DSurface.Viewport3D as Viewport3D;
var vector = viewport3D.GetMainLightDirection();
vector.x = 0.25f;
vector.y = 0.5f;
vector.z = -0.5f;
viewport3D.SetMainLightDirection(vector);

When in static lighting mode, light direction vector always matches Camera3D direction vector.

 

See Also